-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global styles revisions: ensure the revisions endpoint permissions match the global styles controller #50270
Global styles revisions: ensure the revisions endpoint permissions match the global styles controller #50270
Conversation
…hes the permissions for the global styles custom post type controller
…t_item_permissions_check, since this is the check against the original global style custom post
if ( ! current_user_can( 'read_post', $post->ID ) ) { | ||
return new WP_Error( | ||
'rest_cannot_view', | ||
__( 'Sorry, you are not allowed to view revisions for this global style.', 'gutenberg' ), | ||
__( 'Sorry, you are not allowed to view this global style.', 'gutenberg' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double-checking, the only intended change in this PR is the wording on this line + adding tests?
In the other PR it looks like a different check was being used. In this case, the current_user_can( 'read_post', $post->ID )
check appears to be consistent with WP_REST_Global_Styles_Controller
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry 🤦
The intention was to ensure the check was exactly the same as WP_REST_Global_Styles_Controller and I copied the translation over as well.
That means the only purpose of this PR is to add 1 x comment and add a test.
Thanks @andrewserong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, thanks for clarifying! 🙂
@@ -265,6 +265,9 @@ public function get_item_permissions_check( $request ) { | |||
return $post; | |||
} | |||
|
|||
/* | |||
* The same check as WP_REST_Global_Styles_Controller->get_item_permissions_check. | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding comment for context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Confirmed that the check matches that used by WP_REST_Global_Styles_Controller
✅ Tests look good and pass
LGTM! ✨
What
Let's ensure that the endpoint for global styles revisions matches the permissions for the global styles custom post type controller. Huzza!
Why
So that
I'm talking:
WP_REST_Global_Styles_Controller->get_item_permissions_check
See #50089 for context
How?
Looking at how we manage permissions for the stored global styles custom post rest controller, and copying it.
Testing Instructions
Run the tests!
npm run test:unit:php -- --filter Gutenberg_REST_Global_Styles_Revisions_Controller_Test